<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>约健</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    {include file="public:headfile"}
</head>

<body class="hold-transition sidebar-mini">
<div class="wrapper">

    {include file="public:head"}

    {include file="public:slidemenu"}

    <div class="content-wrapper">

        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>权威大师管理</h1>
                    </div>
                </div>
            </div>
        </section>



        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <button class="btn btn-default" data-toggle="modal" data-target="#addModal">添加权威大师</button>
                            <form class="form-inline ml-3 pull-right" action="{:url('index')}" method="post">
                                <div class="input-group input-group-sm">
                                    <input class="form-control form-control-navbar" type="text" placeholder="Search" name="keyword" aria-label="Search">
                                    <div class="input-group-append">
                                        <button class="btn btn-default" type="submit">
                                            <i class="fa fa-search"></i>
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <table class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th> 大师编号</th>
                                    <th> 大师姓名</th>
                                    <th> 头像</th>
                                    <th> 简介</th>
                                    <th> 是否推荐</th>
                                    <th> 操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name='list' id='vo'}
                                <tr>
                                    <td> {$vo.masterid}</td>
                                    <td> {$vo.mastername}</td>
                                    <td><img src="__STATIC__/img/{$vo.masterpic}" style="height: 60px;width: auto;" alt="图片暂无"></td>
                                    <td> <pre style="display: -webkit-box;-webkit-line-clamp: 3行数;-webkit-box-orient: vertical;overflow: hidden;">{$vo.masterintro}</pre></td>
                                    <td> <?php if($vo['masterflag']==1) echo '是'; else echo '否'; ?></td>
                                    <td>
                                        <a class="btn btn-default" href="{:url('master_controller/setFlag',['masterid'=>$vo['masterid']])}"><?php if($vo['masterflag']==1) echo '取消推荐'; else echo '设置推荐'; ?></a>
                                        <button class="btn btn-default" data-masterid="{$vo.masterid}" onclick="update(this)">修改</button>
                                        <a class="btn btn-default" href="{:url('master_controller/delete',['masterid'=>$vo['masterid']])}">删除</a>
                                        <a class="btn btn-default" href="{:url('master_controller/videolist',['masterid'=>$vo['masterid']])}">查看视频列表</a>
                                    </td>
                                </tr>

                                {/volist}
                                </tbody>
                            </table>
                        </div>
                        <!-- /.card-body -->
                        <div class="dataTables_paginate paging_simple_numbers">{$list->render()}</div>
                    </div>
                    <!-- /.card -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->

    </div>
</div>

{include file="public:footfile"}

</body>


<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="addModalLabel">添加精彩活动</h4>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body">
                <form role="form" action="{:url('master_controller/add')}" method="post" enctype="multipart/form-data" name="form1">
                    <div class="card-body">
                        <div class="form-group">
                            <label>大师姓名：</label>
                            <input type="text" name="mastername" class="form-control" placeholder="请填写大师姓名">
                        </div>
                        <div class="form-group">
                            <label>头像：</label>
                            <input type="file" name="masterpic" class="form-control">
                        </div>
                        <div class="form-group">
                            <label>简介：</label>
                            <textarea name="masterintro" cols="25" rows="3" class="form-control"></textarea>
                        </div>
                        <input type="hidden" name="masterflag" value="0">
                    </div>

            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary">提交更改</button>
                </form>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="updateModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="updateModalLabel">修改权威大师</h4>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body">
                <form role="form" action="{:url('master_controller/update')}" method="post" enctype="multipart/form-data" name="form1">
                    <div class="card-body">
                        <div class="form-group">
                            <input type="hidden" name="masterid" id="masterid">
                            <label>大师姓名：</label>
                            <input type="text" name="mastername" id="mastername" class="form-control" placeholder="请填写大师姓名">
                        </div>
                        <div class="form-group">
                            <label>头像：</label>
                            <input type="file" name="masterpic" class="form-control">
                        </div>
                        <div class="form-group">
                            <label>原图片：</label>
                            <img id="yuan_pic" src="__STATIC__/img/logo.jpg" alt="没有原图片" class="form-control" style="height: auto; width: 100px;" >
                        </div>
                        <div class="form-group">
                            <label>简介：</label>
                            <textarea name="masterintro" id="masterintro" cols="25" rows="3" class="form-control"></textarea>
                        </div>
                    </div>

            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary">提交更改</button>
                </form>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>


<script>
    function update(that)
    {
        var masterid=$(that).attr('data-masterid');
        $.ajax({
            url:"{:url('detail_json')}",
            data:{
                masterid:masterid
            },
            dataType:'json',
            success(data){
                $('#masterid').val(masterid);
                $('#mastername').val(data.mastername);
                $('#yuan_pic').attr('src','__STATIC__/img/'+data.masterpic);
                $('#masterintro').val(data.masterintro);
                $("#updateModal").modal('show');
            }
        })
    }
</script>




</html>